Something nasty is filthy, foul, dirty, or awful. Nasty isn't a word for anything nice.
The main meaning of nasty is for things that are unpleasant and very gross. If someone throws up in class, at least one student will probably say, "That's nasty!" The smell of a bathroom is nasty. A song full of dirty words is nasty in a different way. Nasty can also mean "extremely." In football, a vicious hit can be called a nasty hit. A mean person is a nasty person too.