My guess is it's legal to have a phone that can be programmed to perform activities at specified times. You'd essentially just be making robo-calls/robo-texts, which lots of people do. For example, I get a lot of texts from political campaigns, and I wouldn't be surprised if these were written then scheduled to automatically go out at a certain time.
That being said, fabricating evidence is clearly a crime. So, I suspect that you could legally build and possess such a device, but could be guilty of a crime depending on how you use it. The same could be said of probably any non-contraband object.
Again, don't build one of these on my say-so. I'm just speculating.
As to the second part of your question--how the law would look at this kind of evidence in light of the possibility of fabricating it--that really depends on the jury. As it would play out in court, the party presenting the phone evidence would try to convince the jury that it's authentic, e.g. with expert testimony. Likewise, the other party could try to raise doubts as to its authenticity, perhaps by bringing expert witnesses of their own, who would testify about how easy it is to fake and such. And then it would be the jury's decision to give the evidence as much or as little weight as they see fit. So, there's no one-size-fits-all answer. It would depend entirely on the case each side makes and the whims of the jury.
For a fake alibi, making fake calls at the night of the crime is probably not the best option.
Just a though experiment: Would a mobile phone with these possibilities (sending messages with specific data at a specific time, or calling another phone of this type and transmit preproduced sound input, all without being able to distinguish between a "timed" message/call and a normal one) be a legal electronic device? If so, will they change how the law looks at evidence of this kind?