For example i've seen a premade where one had 1500 rating and the other was unranked, will the rest of the team be closer to the higher or the lowest? And what about the other team? Isn't matchmaking somehow unbalanced?
In extreme brief:
And now, the "TS;DR" version ;-):
Source, from which I paraphrase extensively.
There are three cases worth considering (all other cases are some amalgam of these):
The goal of the matchmaking system is to find what is approximately the team's Elo and find a team with a comparable Elo. That translates into having a 50-50 chance of either team winning. The longer you're in queue, the greater the difference between two teams' approximate Elo is allowed, thus the greater difference in your estimated percentage chance to win.
At the root of the question is how that number is determined.
In the root-case of everyone being in solo-queue, in any game type, the system first locates other people approximately your same Elo then loads you all into a team and averages the Elo of each member. Once it has two teams "in queue" with approximately the same team Elo, it will match them into a game.
On the other extreme, if you're a 5-man pre-made team, the same process is followed except the team is already full (so it doesn't need to locate other players for the team), and the team Elo gets a small bonus (described below). In ranked games, you will only be matched against another 5-man pre-made team. In normal games, I believe (and ought be corrected or confirmed with an edit and source citation) that 5-man pre-made teams are preferred but you don't necessarily get matched with one.
In the middle, things are slightly more complicated. Once you enter a queue with teammates, everyone's Elo is adjusted to be the same value. That value is the average of everyone's Elo plus, again, a bonus depending on several factors (again, see below). Once you're all in the pool of active game-seekers, it locates other players who have approximately the same Elo as your adjusted Elo. Obviously, when it examines another player's Elo it could be looking at their adjusted Elo, too, in the case that you have a team of 3 and a team of 2 being put on the same team of 5. Once it has created a full team of five, it does a final averaging of the Elo everyone entered the team time (adjusted or not). That final averaging is your team's Elo. It then locates another team with the same team Elo and BAM: puts you in a game.
The question now is what kind of bonuses you get. Riot won't release the exact values, and there are a number of cases to consider. I'll let the a different source do the talking:
Finally, with all of that information, we can address the question of "Isn't matchmaking somehow unbalanced?"
"Unbalanced" we can safely take to mean that it grants advantages to one team or person over another. Since virtually any "person" advantage is also a "team" advantage (you don't gain or lose Elo individually; only as a whole team) I think it's safe to say we don't need to cover them individually. One assumption I am making is that Elo is a fair approximation for skill. Disagree all you like, but some assumption of the system's validity needs to be made in order to discuss it.
Riot obviously has gone through significant effort to make sure that the system is difficult to abuse. I also won't speculate on measures we're not fully aware of (Newbie Island and abuse detection). However, two people of inordinate skill differential (say, 0 and 1800) would end up at 900 + some arbitrary bonus if they queue'd together. If you have three people at 0 and one 1800, you would get 450 + some (larger) bonus. An 1800 Elo player can generally be expected to carry a 450 Elo game and a 0 Elo player is unlikely going to be able to throw it. In this sense, the system as presented can be abused.
If we take a more realistic case, however, of an 1800 Elo player helping a 1200 Elo player (let's say their Elo has stabilized; I know you get significant (40+) Elo gains and losses early on), the difference is less pronounced. That would put them at 1500 Elo, plus a bonus, which a 1200 Elo player can certainly throw due to the ability of the 1500 Elo players to take advantage of their mistakes (something that 450 Elo players have a harder time doing). However, the 1800 Elo player is going to have a harder time carrying the game alone.
You can see that, even without extra knowledge of the system, it's hard to make the situation measurably "unbalanced" for the majority of cases.
The ranking system will put together a team of players each with their ranging ELO values. It will general try and keep people similar to each other but it does not always happen.
After that is done, it will simply look for another team that is similar and it will keep increasing the amount the teams can be different until it will find a match. This searching scales as time passes under the theory of getting into a game sooner rather than a more perfectly matched game is more desirable.
You can search the posts here for a more clear explanation of ELO if you are interested to take it further :)
Hope this helps.