It depends. Just because your program runs on the bare metal it doesn't mean it's an OS. As a bare minimum it would also have to define an API that other programs can use, right?
My point is that when the application domain is very well defined, one can use the extra knowledge to make assumptions that no general purpose OS would be allowed to make.
That produces devices that run faster and/or burn less energy. And might even be more secure, if anything because there are fewer moving parts, but that's not always a given.