One of the things your back leg does when you serve is that it helps you stay on balance when you follow through and when you land on your front foot (if you jump during your service motion, of course). Because your upper body leads when you serve and you are exploding up and into the court, your upper body gets ahead of your lower body. You therefore need something to serve as a counterbalance to your upper body when you land and follow through.
At 0:25 in the video above, you can see Oliver Akli hitting a flat serve. Notice that as Oli swings, he explodes up and into the tennis court and his upper body gets out into the court ahead of his lower body. That’s why, as he comes back down to the ground, he kicks his back leg upwards to serve as a counterbalance as his front foot comes down to the ground. The other key point to take in here is that his back leg doesn’t just kick out in any random direction. It kicks up almost straight back because his weight is moving basically exactly the opposite direction, straight into the court.
What this should tell you about your own serve is that if you notice your leg kicking out in a direction that is not straight back, it may mean that you are not getting your body weight moving correctly into the tennis court during your service motion.