Like user2808054 says, if you're just messing around at home, you can do what you want.
But if you're going to start publicly displaying your music (for money or not) a number of different rules start cropping up, such as copyright, and various other Creative Commons licences.
Arrangements
If you write an arrangement of a piece, you need to give credit to the original "authors", which may include composer and lyricist. As long as you provide proper reference, and your arrangement is "different enough" from the original, that's fine.
Musical Phrases
Some publishers may not allow for remixing of certain current songs (by current I mean the singer/songwriter is still alive and making money from sales). If you are just using a tune/phrase "snippit" from a piece in your composition, usually that's ok as long as it does not make up a significant portion of your overall work. Be careful that if you're using a collection of phrases from different works from the same artist that they get "concerned" about it. This YouTube video ("John Williams is the Man") had initially received some criticism (and almost a lawsuit) from the publishers because the whole song used musical phrases from a collection of songs all from John Williams. The artist eventually came to an agreement with the publishers and added the song and movie titles as super/sub titles in the video.
When in doubt, include a reference to the original work you're using.
Copyright
Depending on what kind of work it is, Copyright may persist long after the author is dead. Even then, the artists family may apply for an extension which would transfer the rights to the artists family. From the Wikipedia entry on "Copyright":
In most of the world, the default length of copyright is the life of
the author plus either 50 or 70 years. In the United States, the term
for most existing works is a fixed number of years after the date of
creation or publication. Under most countries' laws (for example, the
United States[39] and the United Kingdom[40]), copyrights expire at
the end of the calendar year in question.
I hope this helps, and have fun!