The gravitational interactions of numerous massive objects are too complex to solve exactly. There are simplified solutions where the gravitational pull of one object is ignored. Such solutions are reasonable approximations to the situation where one body is much more massive than the other, such as a star being orbited by a planet or asteroid. It is this model which produces elliptical orbits.
There is a 2nd level of simplified solution where the gravitational pull of two bodies are taken into account and the gravity of a 3rd object is ignored. This is a decent approximation for the case where the 3rd body is far less massive than either of the other two, such as an asteroid relative to a planet and its parent star. This simplification produces slightly more complex results than mere ellipses. The two more massive objects orbit the barycenter between each other, in many cases the barycenter will be within the larger object (especially in cases of stars orbited by planets), in cases of binary stars or binary planets the barycenter may lie between the bodies.
In the case of a star that is much more massive than a planet the planet's orbit approximates an ellipse, but the interactions of a 3rd body are more complicated. There is a volume of space where a 3rd body would orbit only the star, and a much smaller volume of space where a 3rd body would orbit the planet. There are also 5 other volumes where more interesting interactions occur, these are called Lagrangian Points. Along the axis of the planet and star there are 3 such points, one between (L1), one behind the planet (L2), and one opposite the planet and behind the star (L3). Objects at these points can stay at these points indefinitely. However, these points are only quasi-stable, small perturbations of objects at these points will tend to cause them to drift away from them, until eventually they're just in solar orbit. Spacecraft can stay at or near these points because they can perform small trajectory adjustments over time. The other two points lie along the planet's orbit, 60 degrees ahead (L4) or behind (L5) the planet. These points, volumes more precisely, are truly stable, objects near them will tend to stay in the same area over long periods (up to billions of years). Hundreds of thousands of asteroids exist in "lissajous" orbits around these "trojan" points near Jupiter and Saturn, even Mars has a handful.
2010 TK7 appears to exist in an orbit that transitions back and forth between the Earth-Sun L4 region and L3. Given that it may be that this asteroid has become captured around L4/L3 only relatively recently.