In order to dance well in any style, you need to be able to understand the beat of the music. Listen to a wide variety of music and tap your foot along to the tunes, counting as you go. If you can feel the beat and rhythm of the music, you will be able to dance to it. Learn to tell the difference between songs written in different time signatures by listening and counting. For example, a waltz is counted in beats of three, while most pop songs are counted in beats of four.
When dancing, stay focused on everything around you. Listen to the music as it changes and carefully pay attention to those that you are dancing with, or who are watching you dance. Improvising is about taking what you are given and running with it, and to do that you need constant awareness.
When you freestyle dance, be careful to not get stuck in any given pattern. People who are new to freestyle and improvisational dance quickly get stuck in ruts of moves that feel comfortable. Make a conscious effort to break out of any consistent movement patterns. Focus on performing in new ways, such as changing your arms or feet movements in order to break out out of any repetitive segments.
Don't focus on mistakes and worry or dwell on them. This only sucks the fun out of the dance. Instead, ignore your mistakes and focus on continuing to dance. Fluidity and confidence is more important than some sort of imposed perception of perfection, so don't worry about it if you make a mistake. The beauty of freestyle is that there really is no "wrong" way to dance. Stay on beat and continue to move with confidence, and no one but you will know that something ever went wrong.