Hi and welcome.
Your iTunes library is normally to be found at Macintosh HD > Users > YourName > Music > iTunes
It might differ if you've changed things in the past, but that's the first place to look.
Taking your question at face value: if you want to go back in time and replace the entire library and its contents, playlists etc from Time Machine, this is what you do -
1. Open Finder and navigate to your iTunes Library. Keep that Window open.
2. Click on the Time Machine icon in the top menu bar - from the drop down, choose "Enter Time Machine" (NB DO NOT try to open Time Machine from Finder).
3. When you Enter Time Machine, it will, or should, display the Window you had left open in step 1.**
4. On your right side, will be a timeline. Select a date from the timeline when you are sure that iTunes was functioning normally; by clicking on it. Wait - I mean wait.
5. After a few seconds, it will have gone back to that date and the window (from step 1) should be displayed.**
6. Click on the iTunes library to highlight it.
7. At the bottom of your screen, you have 2 choices "Restore" or "Cancel" (in older versions, Restore was on the left side, I think, and cancel on the right). Choose restore. Wait, again wait. When the restore is done, it may ask you if you want to keep both versions or replace.
You should choose Replace.
Then, when that is done, quit out of Time Machine.
** If for any reason, the original window from step 1, is not showing, then navigate to your iTunes Library as you did before.
Now that deals with your question as stated; but once you've restored things, there is the question of why it got screwed up in the first place. We want to avoid that, so come back to us before you start syncing things, please.
Ian