Can I exit and reenter the airport within the available time or will I miss my flight?
You probably have enough time. Your friends should travel to the airport to maximize the chance that you will see them, of course.
You will have to be prepared for any of a number of factors that could spoil your plans. Most notable among them:
- A delayed incoming flight
- Long queues at entry immigration when you try to get out to meet your friends
- Long queues at security to re-enter the airport
- Long queues at exit immigration to get to your gate
As you make your way to the outer (unsecured) area of the airport to meet your friends, have a look at the security and exit immigration queues you'll need to wait in before getting to your gate. This will give you a better idea of how much time you will need to get to your gate promptly.
Will this get me into trouble with the immigration authorities if I reenter after only a few hours?
Note that you're actually entering the Schengen area when you leave the airport and exiting it when you go to your gate.
Your valid Schengen visa will authorize you to pass through entry immigration (assuming you haven't already exhausted your 90 days' allowed stay in the previous 179 days); you will also of course have to convince the immigration officer to admit you. There's nothing wrong by itself with a plan to meet friends during your layover; people do this all the time, but of course it is impossible to predict whether in your case (or in any specific case) the immigration officer will allow it.
Finally, you have not actually given us enough information to know whether you will have to pass through immigration to leave the airport in Frankfurt. We get many questions that demonstrate a misunderstanding of the situation, so I will cover this question even though you did not ask it:
[Will I even need to pass through immigration controls to leave the airport?]
This depends on where you are coming from. The immigration considerations apply only if your arriving flight originated outside the Schengen area. In other words, if you are flying from Paris (or Ljubljana or Bilbao or any other Schengen airport), you will not need to clear entry immigration controls to leave the airport, and, whether you leave the airport or not, you will need to clear exit immigration to reach your departure gate.)