In rap, freestyle is used in two main ways. In some cases, people mean that a rapper is coming up with lines on the spot, improvising off the top of his or her head. Rappers who do this are often given a topic or word randomly, and they'll rhyme from there.
In other cases, freestlying can mean that a rapper is presenting in a kind of free associative way where there is no set topic. It's thought of as "free" in part because it does not adhere to a set structure like a verse of a song on the radio. The rapper might have previously written or composed the lines and then decided to present the lyrics in a freestyle session.